<?php

class tplTutors extends StudyBuddy\Template\Template
{

	protected static function func(&$a) {
		$subject = array('English', 'Malay', 'Chem', 'Science', 'Amaths', 'Geography');
		if(!empty($a['teach'])){
			$a['canTeach'] = '';
			$canteach = explode(',',$a['teach']);
			for($i = 0 ; $i < count($subject) ; $i++){
				for($j = 0 ; $j < 9; $j++){
					if($canteach[$j + ($i * 9)] == 1){
						if(!strpos($a['canTeach'], $subject[$i]) ){
							$a['canTeach'] .= $subject[$i].', ';
						}
					}
				}
            }
			$a['canTeach'] = substr($a['canTeach'], 0, -2);
		}
		if(empty($a['experience'])){
			$a['experience'] = '0';
		}
		if(empty($a['mobile'])){
			$a['mobile'] = 'No number';
		}
		if(!empty($a['avatar_external'])){
			$a['avtr'] = $a['avatar_external'];
		}else{
			if(!empty($a['avatar'])){
				$a['avtr'] = '/w/img/avatar/sqr/' . $a['avatar'];
			}else{
				$a['avtr'] = '/images/avatar.png';
			}
		}
	}
	
	protected static $vars = array(
		'_id' => '0', //1
		'username' => '', //2
		'fullname' => '', //3
		'avtr' => '/images/avatar.png', //4
		'experience' => '0', //5
		'canTeach' => '', //6
		'mobile' => '', //7
	);

	protected static $tpl = '<div style="width:280px; height:120px; float: left; margin-left: 5px; margin-top: 5px; background: #ff8e33;">
								<div style="float:left; padding: 10px;">
									<a href="/users/%1$s/%2$s"><img alt="" src="%4$s" width="60px"/></a>
								</div>
								<div style="float:left; padding: 10px; width: 180px;">
									<div>%3$s</div>
									<div>%7$s</div>
									<div>Exp: %5$s years</div>
									<div>%6$s</div>
								</div>
							</div>';
}